package gui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import main.Logger;

public class ChatPane extends JPanel implements ActionListener, Observer {
	private JTextArea area;
	private JTextField field;

	public ChatPane() {
		super(new BorderLayout(2,1));
		area = new JTextArea();
		
		field = new JTextField();
		field.addActionListener(this);
		
		add(area, BorderLayout.CENTER);
		add(field, BorderLayout.SOUTH);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		area.setText(area.getText() +"<you> "+ field.getText() +"\n");
		field.setText("");
	}

	@Override
	public void update(Observable o, Object t) {
		area.setText(area.getText() +"-- "+ t + " --\n");
	}
}
